package com.controller;

import com.exception.BusinessException;
import com.exception.NotFoundException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @GetMapping("")
    public String index(){
        //内部500测试
//        int i = 1/0;
        return "/index";
    }

    @RequestMapping("/error/{i}")
    public String Error(@PathVariable("i") int i){
        if(i==1){
            throw new BusinessException("业务错了");
        }
        if(i==2){
            throw new NotFoundException("这儿没有");
        }
        return "/index";
    }
}
